<template>
  <div class="dashboard">
    <div class="header">
      <div :class="['title', 'title-' + titleClass]"></div>
    </div>
    <div class="route-btn back" v-if="titleClass === 'charts'" @click="handleRoute(titleClass)">返回</div>
    <div class="route-btn skip" v-if="titleClass === 'manage'" @click="handleRoute(titleClass)">数据分析</div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "dashboard",
  data() {
    return {
      titleClass: 'manage'
    }
  },
  watch: {
    '$route.path': {
      deep: true,
      immediate: true,
      handler(path) {
        this.titleClass = path === '/dashboard/index' ? 'manage' : 'charts'
      }
    }
  },
  methods: {
    handleRoute(type) {
      let url = type === 'manage' ? 'charts' : 'index'
      this.$router.push('/dashboard/' + url)
    }
  }
}
</script>

<style lang="scss" scoped>
  .dashboard {
    width: 1920px;
    height: 1080px;
    background: url("../../assets/dp-imgs/bg@2x.png") no-repeat;
    background-size: 100% 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    .route-btn {
      position: absolute;
      top: 100px;
      color: #fff;
      width: 91px;
      text-align: center;
      height: 32px;
      line-height: 32px;
      background: #0154BE;
      border: 1px solid #000000;
      font-size: 16px;
      cursor: pointer;
      &.back {
        left: 38px;
      }
      &.skip {
        right: 38px;
      }
    }
    .header {
      height: 105px;
      background: url("../../assets/dp-imgs/header@2x.png") no-repeat left bottom;
      background-size: 100% 79px;
      position: relative;
      .title {
        width: 567px;
        height: 37px;
        position: absolute;
        left: 50%;
        top: 24px;
        transform: translateX(-50%);
        &-manage {
          background: url("../../assets/dp-imgs/title@2x.png") no-repeat;
          background-size: 100% 100%;
        }
        &-charts {
          background: url("../../assets/dp-imgs/title-charts@2x.png") no-repeat;
          background-size: 100% 100%;
        }
      }
    }
  }
</style>
